package com.xy.biz.uc.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.biz.uc.domain.bo.SignatureBO;
import com.xy.biz.uc.domain.po.SignaturePO;
import com.xy.biz.uc.domain.query.SignatureQuery;
import com.xy.biz.uc.domain.req.GetSignatureByUserIdRequest;
import com.xy.biz.uc.domain.resp.GetSignatureResponse;
import com.xy.biz.uc.domain.req.SaveSignatureRequest;
import com.xy.biz.uc.domain.req.ListSignatureRequest;
import com.xy.tool.util.BeanUtilsEx;

/**
 *
 *
 * @author yzh
 * @date 2021-2-22
 */
public class SignatureConverter {

	public static SignaturePO toPO(SignatureBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new SignaturePO(), true);
	}

	public static List<SignaturePO> toPO(Collection<SignatureBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new SignaturePO(), true);
	}

	public static SignatureBO fromPO(SignaturePO source) {
		return BeanUtilsEx.copyProperties(source, () -> new SignatureBO());
	}

	public static List<SignatureBO> fromPO(Collection<SignaturePO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new SignatureBO());
	}

	public static SignatureBO toBO(SaveSignatureRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new SignatureBO(), true);
	}

	public static SignatureBO toBO(SignaturePO source) {
		return BeanUtilsEx.copyProperties(source, () -> new SignatureBO(), true);
	}

	public static List<SignatureBO> toBO(Collection<SaveSignatureRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new SignatureBO(), true);
	}

	public static GetSignatureResponse toResponse(SignatureBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetSignatureResponse());
	}

	public static List<GetSignatureResponse> toResponse(Collection<SignatureBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetSignatureResponse());
	}

	public static SignatureQuery toQuery(ListSignatureRequest source) {
		if(null == source) {
			return null;
		}
		SignatureQuery target = new SignatureQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

	public static SignatureQuery toQuery(GetSignatureByUserIdRequest source) {
		if(null == source) {
			return null;
		}
		SignatureQuery target = new SignatureQuery();
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
